import json
import urllib.request

if __name__ == '__main__':
    # jsonobj=json.load(open("test.json",encoding='utf-8'))
    # print(jsonobj)
    # url="https://dianying.taobao.com/showAction.json?_ksTS=1679819657435_64&jsoncallback=jsonp65&action=showAction&n_s=new&event_submit_doGetSoon=true"
    # url="https://dianying.taobao.com/showAction.json?_ksTS=1679819657435_64&action=showAction&n_s=new&event_submit_doGetSoon=true"
    url="https://dianying.taobao.com/cityAction.json?activityId&_ksTS=1679819842170_236&action=cityAction&n_s=new&event_submit_doGetAllRegion=true"
    headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
        "referer": "https://dianying.taobao.com/"
    }

    request=urllib.request.Request(url=url,headers=headers)

    result=urllib.request.urlopen(request)
    content=result.read().decode("utf-8")
    print(type(content))
    # print(content)
    # urllib.request.urlretrieve(request,"json/1.json")
    obj=json.loads(content)
    print(type(obj))
    with open("json/2.json",mode="w",encoding="utf-8") as fs:
        fs.write(content)
    print(obj)
